package com.appkubes.mall.admin.application.goods.sku.controller;

import com.appkubes.common.Response;
import com.appkubes.mall.admin.application.base.BaseController;
import com.appkubes.mall.admin.application.goods.sku.entity.vo.AttributeVO;
import com.appkubes.mall.admin.application.goods.sku.service.SpecificAttributeService;
import com.appkubes.mall.admin.application.goods.sku.service.impl.SpecificAttributeServiceImpl;
import com.appkubes.mall.admin.config.camel.RequestModel;
import com.appkubes.mall.core.po.MallSpecificAttribute;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api("多规格属性")
@RestController
@RequestMapping("/sass_admin/Sspecificattribute")
public class SpecificAttributeController extends BaseController {
    @Autowired
    SpecificAttributeService specificAttributeService;

    @ApiOperation("增加属性")
    @PostMapping("add")
    public Response add(@RequestModel AttributeVO attributeVO) {
        MallSpecificAttribute mallSpecificAttribute = new MallSpecificAttribute();

        BeanUtils.copyProperties(attributeVO, mallSpecificAttribute);
        specificAttributeService.add(mallSpecificAttribute);
        return Response.success(mallSpecificAttribute);
    }

    @ApiOperation("删除规格")
    @PostMapping("del")
    public Response del(@RequestParam(defaultValue = "") String key) {
        return Response.success(specificAttributeService.del(key));
    }
}
